package com.fc.test.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.fc.test.common.base.BaseService;
import com.fc.test.common.support.Convert;
import com.fc.test.mapper.auto.TAbbPinglunMapper;
import com.fc.test.model.auto.TAbbPinglun;
import com.fc.test.model.auto.TAbbPinglunExample;
import com.fc.test.model.custom.Tablepar;
import com.fc.test.util.SnowflakeIdWorker;

/**
 * Service
* @Title: TAbbPinglunService.java 
* @Package com.fc.test.entity 
* @author fuce
* @email 87766867@qq.com
* @date 2019-08-22 18:34:02  
 */
@Service
public class TAbbPinglunService implements BaseService<TAbbPinglun, TAbbPinglunExample>{
	@Autowired
	private TAbbPinglunMapper tAbbPinglunMapper;

	/**
	 * 分页查询
	 * @param pageNum
	 * @param pageSize
	 * @return
	 */
	 public PageInfo<TAbbPinglun> list(Tablepar tablepar,String name,String id){
	        TAbbPinglunExample testExample=new TAbbPinglunExample();
	        testExample.setOrderByClause("id ASC");
		   TAbbPinglunExample.Criteria criteria= testExample.createCriteria();
	        if(name!=null&&!"".equals(name)){
				criteria.andUsernameLike("%"+name+"%");
	        }
		    criteria.andGoodsidEqualTo(id);
	        PageHelper.startPage(tablepar.getPageNum(), tablepar.getPageSize());
	        List<TAbbPinglun> list= tAbbPinglunMapper.selectByExample(testExample);
	        PageInfo<TAbbPinglun> pageInfo = new PageInfo<TAbbPinglun>(list);
	        return  pageInfo;
	 }

	@Override
	public int deleteByPrimaryKey(String ids) {
		List<String> lista=Convert.toListStrArray(ids);
		TAbbPinglunExample example=new TAbbPinglunExample();
		example.createCriteria().andIdIn(lista);
		return tAbbPinglunMapper.deleteByExample(example);
	}


	@Override
	public TAbbPinglun selectByPrimaryKey(String id) {

		return tAbbPinglunMapper.selectByPrimaryKey(id);
	}


	@Override
	public int updateByPrimaryKeySelective(TAbbPinglun record) {
		return tAbbPinglunMapper.updateByPrimaryKeySelective(record);
	}

	/**
	 * 添加
	 */
	@Override
	public int insertSelective(TAbbPinglun record) {
		//添加雪花主键id
		record.setId(SnowflakeIdWorker.getUUID());
		return tAbbPinglunMapper.insertSelective(record);
	}










	@Override
	public int updateByExampleSelective(TAbbPinglun record, TAbbPinglunExample example) {

		return tAbbPinglunMapper.updateByExampleSelective(record, example);
	}


	@Override
	public int updateByExample(TAbbPinglun record, TAbbPinglunExample example) {

		return tAbbPinglunMapper.updateByExample(record, example);
	}

	@Override
	public List<TAbbPinglun> selectByExample(TAbbPinglunExample example) {

		return tAbbPinglunMapper.selectByExample(example);
	}


	@Override
	public long countByExample(TAbbPinglunExample example) {

		return tAbbPinglunMapper.countByExample(example);
	}


	@Override
	public int deleteByExample(TAbbPinglunExample example) {

		return tAbbPinglunMapper.deleteByExample(example);
	}


	public List<TAbbPinglun> getHuigouGoodsPinglun(String goodsid,int page){
		Map<String,Object> paramMap = new HashMap<>();
		paramMap.put("goodsid",goodsid);
		paramMap.put("page",page);
		List<TAbbPinglun> list = tAbbPinglunMapper.getHuigouGoodsPinglun(paramMap);
		return list;
	}

}
